<template>
  <div class="h-full">
    <router-view class="p-b-50" />
    <c-footer></c-footer>
    <!-- <baidu-map @ready="mapReady" ak="GuAVcGnOSpVQS70BaI0vy6IaHPAda65G"></baidu-map> -->
  </div>
</template>

<script>
import { mapMutations } from 'vuex'
// import { BaiduMap } from 'vue-baidu-map/components'
import cFooter from '@/components/cFooter'
export default {
  components: {
    // BaiduMap,
    cFooter
  },
  mounted () {
    this.init()
  },
  methods: {
    ...mapMutations(['changeArea', 'changePoint']),
    init () {
      this.changeArea('郑州市')
      this.changePoint({
        lng: 113.642339,
        lat: 34.753677
      })
    },
    mapReady ({ BMap }) {
      let geolocation = new BMap.Geolocation()
      let geocoder = new BMap.Geocoder()
      let self = this
      geolocation.getCurrentPosition(function (r) {
        if (this.getStatus() === 0) {
          geocoder.getLocation(r.point, async ({ addressComponents, point }) => {
            self.changeArea(addressComponents.district)
            self.changePoint({ ...point })
          })
        } else {
          self.$toast('定位失败, 请手动选择位置')
        }
      }, { enableHighAccuracy: true })
    }
  }
}
</script>
